<!doctype html>


<html>
<head>
  <link rel="shortcut icon" href="static/images/favicon.ico" type="image/x-icon">
  <title>integer.js (Closure Library API Documentation - JavaScript)</title>
  <link rel="stylesheet" href="static/css/base.css">
  <link rel="stylesheet" href="static/css/doc.css">
  <link rel="stylesheet" href="static/css/sidetree.css">
  <link rel="stylesheet" href="static/css/prettify.css">

  <script>
     var _staticFilePath = "static/";
  </script>

  <script src="static/js/doc.js">
  </script>

  <meta charset="utf8">
</head>

<body onload="prettyPrint()">

<div id="header">
  <div class="g-section g-tpl-50-50 g-split">
    <div class="g-unit g-first">
      <a id="logo" href="index.html">Closure Library API Documentation</a>
    </div>

    <div class="g-unit">
      <div class="g-c">
        <strong>Go to class or file:</strong>
        <input type="text" id="ac">
      </div>
    </div>
  </div>
</div>





<div class="colmask rightmenu">
<div class="colleft">
    <div class="col1">
      <!-- Column 1 start -->

<div id="title">
       <span class="fn">integer.js</span>
</div>

<div class="g-section g-tpl-75-25">
  <div class="g-unit g-first" id="description">
    Defines an Integer class for representing (potentially)
 infinite length two&#39;s-complement integer values.

 For the specific case of 64-bit integers, use goog.math.Long, which is more
 efficient.
  </div>
  

        <div class="g-unit" id="useful-links">
          <div class="title">Useful links</div>
          <ol>
            <li><a href="closure_goog_math_integer.js.source.html"><span class='source-code-link'>Source Code</span></a></li>
          </ol>
        </div>
</div>

<h2 class="g-first">File Location</h2>
  <div class="g-section g-tpl-20-80">
    <div class="g-unit g-first">
      <div class="g-c-cell code-label">math/integer.js</div>
    </div>
  </div>
<hr/>


  <h2>Classes</h2>
 <div class="fn-constructor">
        <a href="class_goog_math_Integer.html">
          goog.math.Integer</a><br/>
        <div class="class-details">Constructs a two&#39;s-complement integer an array containing bits of the
integer in 32-bit (signed) pieces, given in little-endian order (i.e.,
lowest-order bits in the first piece), and the sign of -1 or 0.

See the from* functions below for other convenient ways of constructing
Integers.

The internal representation of an integer is an array of 32-bit signed
pieces, along with a sign (0 or -1) that indicates the contents of all the
other 32-bit pieces out to infinity.  We use 32-bit pieces because these are
the size of integers on which Javascript performs bit-operations.  For
operations like addition and multiplication, we split each number into 16-bit
pieces, which can easily be multiplied within Javascript&#39;s floating-point
representation without overflow or change in sign.</div>
 </div>
      
<br/>

  <div class="legend">
        <span class="key publickey"></span><span>Public</span>
        <span class="key protectedkey"></span><span>Protected</span>
        <span class="key privatekey"></span><span>Private</span>
  </div>


  <h2>Global Functions</h2>





<div class="section">
  <table class="horiz-rule">


     <tr class="even entry private">
       <td class="access"></td>






  <td>
    <a name="goog.math.Integer.carry16_"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryNamespace">goog.math.Integer.</span><span class="entryName">carry16_<span class="args">(<span class="arg">bits</span>,&nbsp;<span class="arg">index</span>)</span>
        </span>
      </div>


     <div class="entryOverview">
       Carries any overflow from the given index into later entries.
     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">bits</span>
        : <div class="fullType"><span class="type"><a href="http://www.google.com/url?sa=D&q=https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Array">Array</a></span>.&lt;<span class="type"><a href="http://www.google.com/url?sa=D&q=https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Number">number</a></span>&gt;</div>
        <div class="entryOverview">Array of 16-bit values in little-endian order.</div>
     </td>
   </tr>
     
   <tr class="odd">
     <td>
        <span class="entryName">index</span>
        : <div class="fullType"><span class="type"><a href="http://www.google.com/url?sa=D&q=https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Number">number</a></span></div>
        <div class="entryOverview">The index in question.</div>
     </td>
   </tr>
  </table>
      </div>
   
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="closure_goog_math_integer.js.source.html#line558">code &raquo;</a>
  </td>
     </tr>


     <tr class="odd entry public">
       <td class="access"></td>






  <td>
    <a name="goog.math.Integer.fromBits"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryNamespace">goog.math.Integer.</span><span class="entryName">fromBits<span class="args">(<span class="arg">bits</span>)</span>
        </span>
        &#8658; <div class="fullType"><span class="type"><a href="class_goog_math_Integer.html">goog.math.Integer</a></span></div>
      </div>


     <div class="entryOverview">
       Returns a Integer representing the value that comes by concatenating the
given entries, each is assumed to be 32 signed bits, given in little-endian
order (lowest order bits in the lowest index), and sign-extending the highest
order 32-bit value.
     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">bits</span>
        : <div class="fullType"><span class="type"><a href="http://www.google.com/url?sa=D&q=https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Array">Array</a></span>.&lt;<span class="type"><a href="http://www.google.com/url?sa=D&q=https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Number">number</a></span>&gt;</div>
        <div class="entryOverview">The bits of the number, in 32-bit signed pieces, in little-endian order.</div>
     </td>
   </tr>
  </table>
      </div>
   
      <div class="detailsSection">
        <b>Returns:</b>&nbsp;<div class="fullType"><span class="type"><a href="class_goog_math_Integer.html">goog.math.Integer</a></span></div>&nbsp;
            The corresponding Integer value.
      </div>
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="closure_goog_math_integer.js.source.html#line138">code &raquo;</a>
  </td>
     </tr>


     <tr class="even entry public">
       <td class="access"></td>






  <td>
    <a name="goog.math.Integer.fromInt"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryNamespace">goog.math.Integer.</span><span class="entryName">fromInt<span class="args">(<span class="arg">value</span>)</span>
        </span>
        &#8658; <div class="fullType"><span class="type"><a href="class_goog_math_Integer.html">goog.math.Integer</a></span></div>
      </div>


     <div class="entryOverview">
       Returns an Integer representing the given (32-bit) integer value.
     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">value</span>
        : <div class="fullType"><span class="type"><a href="http://www.google.com/url?sa=D&q=https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Number">number</a></span></div>
        <div class="entryOverview">A 32-bit integer value.</div>
     </td>
   </tr>
  </table>
      </div>
   
      <div class="detailsSection">
        <b>Returns:</b>&nbsp;<div class="fullType"><span class="type"><a href="class_goog_math_Integer.html">goog.math.Integer</a></span></div>&nbsp;
            The corresponding Integer value.
      </div>
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="closure_goog_math_integer.js.source.html#line90">code &raquo;</a>
  </td>
     </tr>


     <tr class="odd entry public">
       <td class="access"></td>






  <td>
    <a name="goog.math.Integer.fromNumber"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryNamespace">goog.math.Integer.</span><span class="entryName">fromNumber<span class="args">(<span class="arg">value</span>)</span>
        </span>
        &#8658; <div class="fullType"><span class="type"><a href="class_goog_math_Integer.html">goog.math.Integer</a></span></div>
      </div>


     <div class="entryOverview">
       Returns an Integer representing the given value, provided that it is a finite
number.  Otherwise, zero is returned.
     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">value</span>
        : <div class="fullType"><span class="type"><a href="http://www.google.com/url?sa=D&q=https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Number">number</a></span></div>
        <div class="entryOverview">The value in question.</div>
     </td>
   </tr>
  </table>
      </div>
   
      <div class="detailsSection">
        <b>Returns:</b>&nbsp;<div class="fullType"><span class="type"><a href="class_goog_math_Integer.html">goog.math.Integer</a></span></div>&nbsp;
            The corresponding Integer value.
      </div>
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="closure_goog_math_integer.js.source.html#line112">code &raquo;</a>
  </td>
     </tr>


     <tr class="even entry public">
       <td class="access"></td>






  <td>
    <a name="goog.math.Integer.fromString"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryNamespace">goog.math.Integer.</span><span class="entryName">fromString<span class="args">(<span class="arg">str</span>,&nbsp;<span class="arg">opt_radix</span>)</span>
        </span>
        &#8658; <div class="fullType"><span class="type"><a href="class_goog_math_Integer.html">goog.math.Integer</a></span></div>
      </div>


     <div class="entryOverview">
       Returns an Integer representation of the given string, written using the
given radix.
     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">str</span>
        : <div class="fullType"><span class="type"><a href="http://www.google.com/url?sa=D&q=https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/String">string</a></span></div>
        <div class="entryOverview">The textual representation of the Integer.</div>
     </td>
   </tr>
     
   <tr class="odd">
     <td>
        <span class="entryName">opt_radix</span>
        : <div class="fullType"><span class="type"><a href="http://www.google.com/url?sa=D&q=https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Number">number</a></span></div>
        <div class="entryOverview">The radix in which the text is written.</div>
     </td>
   </tr>
  </table>
      </div>
   
      <div class="detailsSection">
        <b>Returns:</b>&nbsp;<div class="fullType"><span class="type"><a href="class_goog_math_Integer.html">goog.math.Integer</a></span></div>&nbsp;
            The corresponding Integer value.
      </div>
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="closure_goog_math_integer.js.source.html#line151">code &raquo;</a>
  </td>
     </tr>


  </table>
</div>



  <h2>Global Properties</h2>





<div class="section">
  <table class="horiz-rule">


     <tr class="even entry private">
       <td class="access"></td>





  <a name="goog.math.Integer.INT_CACHE_"></a>

  <td>


     <div class="arg">
        <img align="left" src="static/images/blank.gif">

        <span class="entryNamespace">goog.math.Integer.</span><span class="entryName">INT_CACHE_</span>
        : <div class="fullType"><span class="type"><a href="http://www.google.com/url?sa=D&q=https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Object">Object</a></span></div>
     </div>


     <div class="entryOverview">
       A cache of the Integer representations of small integer values.
     </div>

  </td>


  <td class="view-code">
     <a href="closure_goog_math_integer.js.source.html#line82">Code &raquo;</a>
  </td>
     </tr>


     <tr class="odd entry public">
       <td class="access"></td>





  <a name="goog.math.Integer.ONE"></a>

  <td>


     <div class="arg">
        <img align="left" src="static/images/blank.gif">

        <span class="entryNamespace">goog.math.Integer.</span><span class="entryName">ONE</span>
        : <div class="fullType"><span class="type"><a href="class_goog_math_Integer.html">goog.math.Integer</a></span></div>
     </div>


     <div class="entryOverview">
       <span class='nodesc'>No description.</span>
     </div>

  </td>


  <td class="view-code">
     <a href="closure_goog_math_integer.js.source.html#line201">Code &raquo;</a>
  </td>
     </tr>


     <tr class="even entry private">
       <td class="access"></td>





  <a name="goog.math.Integer.TWO_PWR_24_"></a>

  <td>


     <div class="arg">
        <img align="left" src="static/images/blank.gif">

        <span class="entryNamespace">goog.math.Integer.</span><span class="entryName">TWO_PWR_24_</span>
        : <div class="fullType"><span class="type"><a href="class_goog_math_Integer.html">goog.math.Integer</a></span></div>
     </div>


     <div class="entryOverview">
       <span class='nodesc'>No description.</span>
     </div>

  </td>


  <td class="view-code">
     <a href="closure_goog_math_integer.js.source.html#line208">Code &raquo;</a>
  </td>
     </tr>


     <tr class="odd entry private">
       <td class="access"></td>





  <a name="goog.math.Integer.TWO_PWR_32_DBL_"></a>

  <td>


     <div class="arg">
        <img align="left" src="static/images/blank.gif">

        <span class="entryNamespace">goog.math.Integer.</span><span class="entryName">TWO_PWR_32_DBL_</span>
        : <div class="fullType"><span class="type"><a href="http://www.google.com/url?sa=D&q=https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Number">number</a></span></div>
     </div>


     <div class="entryOverview">
       A number used repeatedly in calculations.  This must appear before the first
call to the from* functions below.
     </div>

  </td>


  <td class="view-code">
     <a href="closure_goog_math_integer.js.source.html#line193">Code &raquo;</a>
  </td>
     </tr>


     <tr class="even entry public">
       <td class="access"></td>





  <a name="goog.math.Integer.ZERO"></a>

  <td>


     <div class="arg">
        <img align="left" src="static/images/blank.gif">

        <span class="entryNamespace">goog.math.Integer.</span><span class="entryName">ZERO</span>
        : <div class="fullType"><span class="type"><a href="class_goog_math_Integer.html">goog.math.Integer</a></span></div>
     </div>


     <div class="entryOverview">
       <span class='nodesc'>No description.</span>
     </div>

  </td>


  <td class="view-code">
     <a href="closure_goog_math_integer.js.source.html#line197">Code &raquo;</a>
  </td>
     </tr>


  </table>
</div>



      <!-- Column 1 end -->
    </div>

        <div class="col2">
          <!-- Column 2 start -->
          <div class="col2-c">
            <h2 id="ref-head">Directory math</h2>
            <div id="localView"></div>
          </div>

          <div class="col2-c">
            <h2 id="ref-head">File Reference</h2>
            <div id="sideFileIndex" rootPath="closure/goog" current="math/integer.js"></div>
          </div>
          <!-- Column 2 end -->
        </div>
</div>
</div>

</body>
</html>
